package com.happyfamily.springboot.crowdsourcingplatform.dao.sun;

import com.happyfamily.springboot.crowdsourcingplatform.model.News;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


import java.util.List;

@Mapper
public interface NewDao
{
	@Select("SELECT * FROM news WHERE uaccount=#{uaccount} ORDER BY NTIME DESC LIMIT #{limit} OFFSET #{end}")
	public abstract List<News> getList(String uaccount,Integer limit, Integer end);

	@Select("SELECT COUNT(*) FROM news WHERE uaccount=#{uaccount}")
	public abstract int getSum(String uaccount);

	@Insert("INSERT INTO news (uaccount,ntext,ntime) VALUES (#{uaccount},#{ntext},#{ntime})")
	public abstract int addNews(News news);

	@Delete("DELETE FROM news WHERE nid=#{nid}")
	public abstract int deleteNews(Long nid);
}